package com.joysuch.wwyt.patrol.service;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.joysuch.wwyt.bp.bean.PositionCheckBean;
import com.joysuch.wwyt.core.exception.ApiBusinessException;
import com.joysuch.wwyt.core.exception.ApiCoreException;
import com.joysuch.wwyt.patrol.entity.PatrolTask;
import com.baomidou.mybatisplus.extension.service.IService;
import com.joysuch.wwyt.patrol.entity.bean.*;
import com.joysuch.wwyt.patrol.entity.dto.AppCheckPointDto;
import com.joysuch.wwyt.patrol.entity.dto.AppTaskDto;
import com.joysuch.wwyt.patrol.entity.dto.SimplePointRecordDto;
import com.joysuch.wwyt.patrol.entity.dto.WebTaskDto;
import com.joysuch.wwyt.patrol.entity.vo.CheckPointDetailVo;
import com.joysuch.wwyt.patrol.entity.vo.WebTaskCheckVo;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Date;
import java.util.List;

/**
 * <p>
 *  服务类
 * </p>
 *
 * @author heqifeng
 * @since 2022-02-28
 */
public interface PatrolTaskService extends IService<PatrolTask> {

    void producePatrolTask(Long planId);

    Page<AppTaskDto> appGetTaskList(Long pageNo, Long pageSize);

    Page<WebTaskDto> webGetTaskList(TaskSearchBean searchBean);

    /**
     * 排查记录页面
     * @return
     */
    Page<WebTaskDto> getTaskHadDone(TaskRecordSearchBean searchBean);

    Integer getTaskHadDoneCount(TaskRecordSearchBean searchBean);

    List<AppCheckPointDto> appGetCheckPointByTaskId(Long taskId);

    List<SimplePointRecordDto> appGetCheckPointRecordByTaskId(Long taskId);

    CheckPointDetailVo getItemByPoint(Long pointId);

    /**
     * 隐患排查和巡检列表
     * @param pointId
     * @return
     */
    CheckPointDetailVo getNewItemByPoint(Long pageNo, Long pageSize,Long pointId);

    WebTaskCheckVo getItemByTask(Long taskId);

    /**
     * 返回设备上监测点的列表
     * @param deviceId
     * @return
     */
    List<SimpleMonitoringPointBean> getMonitorByDevice(Long deviceId);

    /**
     * app保存任务记录
     */
    Long appDoTask(AppFinishPointBean pointBean) throws ApiBusinessException;

    /**
     * 获取定位点
     * @return
     */
    String getLocation();

    /**
     * web保存任务记录
     * @param pointBeans
     * @return
     */
    int webDoTask(List<AppFinishPointBean> pointBeans) throws ApiBusinessException;

    /**
     * 位置校验
     * @param pointId
     * @param userId
     * @return
     */
    PositionCheckBean position(Long pointId, Long userId) throws ApiCoreException;

    /**
     * 导出巡检记录
     * @param searchBean
     * @param request
     * @param response
     * @throws IOException
     */
    void exportTaskRecord(TaskRecordSearchBean searchBean, HttpServletRequest request, HttpServletResponse response) throws IOException;

    String getTaskStatus(Long takId);

    Long findLastTaskId(Long planId);

    /**
     * 获取隐患排查和巡检列表
     * @param pageNo
     * @param pageSize
     * @param status
     * @param date
     * @return
     */
    Page<AppSynthesizeBean> synthesizeTask(Long pageNo, Long pageSize, Integer status, Date date,Integer category);
}
